<?php
// +----------------------------------------------------------------------
// | Description: 菜单
// +----------------------------------------------------------------------
// | Author: linchuangbin <linchuangbin@honraytech.com>
// +----------------------------------------------------------------------

namespace app\home\model;
use think\Db;
use think\Model;

class Payorder extends Model
{

    /**
     * 为了数据库的整洁，同时又不影响Model和Controller的名称
     * 我们约定每个模块的数据表都加上相同的前缀，比如微信模块用weixin作为数据表前缀
     */
    protected $name = 'rd_home_order';

    protected $auto = ['create_time'];


    protected function setCreatetimeAttr($value){
        return time();
    }

    protected function getCreatetimeAttr($value){
        return date('Y-m-d H:i:s',$value);
    }


    /**
     * @func 支付宝信息拉取
     * @param $order订单的信息
     * @return bool 订单信息新增成功，返回对应的支付宝信息
     */
    public function saveorder($order){
        $data['uid']=$order['uid'];
        $data['buyid']=$order['id'];
        $data['orderid']=$order['out_trade_no'];
        $data['create_time']=time();
        $data['type']=$order['type'];
        $data['price']=$order['price'];
        $result = db('home_order')->insert($data);
        if($result){
            return true;
        }else{
            return false;
        }
    }

}